import { getNameAndPath } from './utils';
const fs = require('fs-extra');

/**
 * 写入文件 [需要判断目录]
 * @param path      文件路径
 * @param content   文件写入内容
 */
export const writeFiles = async (filesPath: string, content: string) => {
  const _filesPath = getNameAndPath(filesPath);
  try {
    await fs.stat(_filesPath.path);
  } catch (error) {
    await fs.mkdir(_filesPath.path);
  }
  await fs.appendFile(filesPath, content);
};
